<template>
  <div class="colWrapper wrapper">
    <Breadcrumb>
      <BreadcrumbItem>机器管理</BreadcrumbItem>
      <BreadcrumbItem>广告视频上传</BreadcrumbItem>
    </Breadcrumb>
    <div class="form_box">
      <Form ref="formCustom" style="width: 850px;" :model="form" :label-width="100">
        <FormItem label="视频标题:">
          <input type="text" placeholder="请输入"></input>
        </FormItem>
        <FormItem label="视频简介:">
          <textarea type="text" stytle="width:300px;" placeholder="请输入"/>
        </FormItem>
        <FormItem label="上传封面:">
          <div class="colWrapper uploadImg">
            <Button type="success">选择图片</Button>
            <img src="../../assets/imgError.png" alt="">
          </div>
        </FormItem>
        <FormItem label="上传视频:">
          <div class="colWrapper uploadImg">
            <Button type="success">选择图片</Button>
            <img src="../../assets/videoError.svg" alt="">
          </div>
        </FormItem>
        <FormItem label="权重:">
          <input type="text" stytle="width:300px;" placeholder="请输入"/>
        </FormItem>
        <FormItem label="状态:">
          <input type="text" stytle="width:300px;" placeholder="请输入"/>
        </FormItem>
      </Form>
    </div>
    <div class="uploadButton">
      <Button type="success">确定（选择上传设备）</Button>
    </div>
  </div>
</template>

<script>
import '../../style/main.css'

export default {
  data() {
    return {
      form: {
        username: '',
        password: '',
        role_id: null,
        manager_id: null,//经理id 经理角色账号时 不填
        email: '',//邮箱
      },
      selectData: null, // 权限组选中下标
      selectList: [], //权限预览id
      show: true,

      list_: [],

      list: [],
      roleList: [],

      checkAll: true,
      role_id: null,
      data: [],
      accountList: [],
      my_role_id: null, //6经理
    };
  },
  created() {
    // this.m_id = JSON.parse(this.astgo.getItem(this.Pn + "info")).role_id
    this.my_role_id = JSON.parse(this.astgo.getItem(this.Pn + "info")).role_id;
    console.log(this.my_role_id)

  },
  methods: {
    getAccount() { //获取所有经理
      this.axios.post("device/getAccount").then(res => {
        if (res.code === 1) {
          this.accountList = res.data;
        }
      });
    },
    all() {
      this.axios.post("role/rule_list").then(res => {
        if (res.code === 1) {
          this.data = res.data;

        }
      });
    },

    Submit() {
      var form = this.form;
      form.role_id = this.role_id
      console.log(form)

      this.axios.post('account/addAccount', form).then(res => {
        if (res.code === 1) {
          this.$Message.success('添加成功');
          this.$router.go(-1)
        }
      })
    },
    getlist() {
      //如果是经理只能添加操作员
      this.axios.post("role/role_list", {status: 1}).then(res => {
        if (res.code === 1) {
          if (this.my_role_id === 6) {
            this.role_id = 7;
            this.list = [];
            var arr = res.data.list;
            for (var i = 0, len = arr.length; i < len; i++) {
              if (arr[i].id === 7) {
                this.list.push(arr[i]);
                break
              }
            }
          } else {
            this.list = res.data.list;
            this.role_id = this.list[0].id;
            console.log(this.selectData)
          }
          this.selectData = this.list[0].id;
          this.getRole();
        }
      });
    },

    getRole() {
      this.axios.post("role/get_role_rule", {role_id: this.role_id}).then(res => {
        if (res.code === 1) {
          this.list_ = res.data;
          console.log(this.list_)
        }
      })
    },
    changeSelect(e) {
      console.log('选择', e)
      this.show = false;
      this.$nextTick(() => {
        this.show = true
      })
      this.role_id = e;
      this.getRole();
    },
  }
};
</script>

<style scoped>
.wrapper {
  align-items: flex-start;
}

.uploadImg {
  align-items: flex-start;
}

.uploadImg > img {
  margin-top: 20px;
  width: 320px;
  height: 160px;
}

input {
  width: 180px;
}

.uploadButton {
  align-self: center;
}
</style>
